#******************************************************************
#
# Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
##
# Plugin Interface build script
##

import os.path

Import('env')

target_os = env.get('TARGET_OS')

######################################################################
# Build flags
######################################################################
with_upstream = env.get('WITH_UPSTREAM_LIBCOAP')
if with_upstream == '1':
    env.PrependUnique(CPPPATH=['#extlibs/libcoap/libcoap/include'])
else:
    env.PrependUnique(CPPPATH=['#/resource/csdk/connectivity/lib/libcoap-4.1.1/include'])

env.PrependUnique(CPPPATH=[
    '#/resource/c_common/oic_malloc/include',
    '#/resource/c_common/oic_string/include',
    '#/resource/c_common/oic_time/include',
    '#/resource/oc_logger/include',
    '#/resource/csdk/logger/include',
    '#/resource/csdk/stack/include',
    '#/resource/csdk/security/include',
    '#/resource/csdk/include'
])
env.AppendUnique(CPPPATH=[
    '#/plugins/include',
    '#/plugins/include/internal',
    '#/plugins/zigbee_wrapper/include',
    '#/plugins/include/internal'
])

if target_os not in ['windows']:
    env.AppendUnique(CPPDEFINES=['WITH_POSIX'])

if target_os in ['darwin', 'ios']:
    env.AppendUnique(CPPDEFINES=['_DARWIN_C_SOURCE'])

env.AppendUnique(CXXFLAGS=['-std=c++0x', '-Wall', '-Wextra'])

env.PrependUnique(LIBS=['zigbee_wrapper'])

#####################################################################
# Source files and Target(s)
######################################################################
pi_src = [
    'pluginlist.c',
    'plugininterface.c',
]

if target_os in ['android', 'tizen']:
    calib = env.SharedLibrary('plugin_interface', pi_src)
else:
    calib = env.StaticLibrary('plugin_interface', pi_src)
env.InstallTarget(calib, 'plugin_interface')
env.UserInstallTargetLib(calib, 'plugin_interface')
